package com.briup.app01.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.briup.app01.bean.CstCustomer;
import com.briup.app01.bean.CstCustomerExample;
import com.briup.app01.bean.CstCustomerExample.Criteria;
import com.briup.app01.dao.CstCustomerMapper;
import com.briup.app01.service.CstCustomerService;
@Service
public class CstCustomerServiceImpl implements CstCustomerService {
	private static final String region = null;
	private static final String name = null;
	@Autowired
	private CstCustomerMapper customerMapper;
	public void saveOrUpdate(CstCustomer customer) {
		if(customer.getCustId()==null) {
			customerMapper.insertSelective(customer);
		}else {
			customerMapper.updateByPrimaryKey(customer);
	     }
	}
	public void deleteById(long id) {
		customerMapper.deleteByPrimaryKey(id);
	}
	public CstCustomer selectById(long id) {
		return customerMapper.selectByPrimaryKey(id);
	}
	
	public List<CstCustomer> select(String cust_name, String place) {
		CstCustomerExample example = new CstCustomerExample();
    	Criteria criteria = example.createCriteria();
    	if(cust_name!=null) {
    		criteria.andCustNameLike("%"+name+"%");
    	}
    	if(place!=null) {
    		criteria.andCustRegionLike("%"+region+"%");
    }
    		return customerMapper.selectByExample(example);
	}
	public void saverOrUpdate(CstCustomer customer) {
		// TODO Auto-generated method stub
		
	}
	public List<CstCustomer> select(String name, String region, String addr) {
		// TODO Auto-generated method stub
		return null;
	}
	
	
}
